<?php

namespace App\Http\Requests\Mp;

use Illuminate\Foundation\Http\FormRequest;

/**
 * Class StoreChildren
 * @package App\Http\Requests\Mp
 */
class StoreChildren extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required',
            'sex' => 'required',
            'relation' => 'required',
            'avatar' => 'required',
            'morning_rule' => [
                'required',
                'integer'
            ],
            'lunch_rule' => [
                'required',
                'integer'
            ],
            'dinner_rule' => [
                'required',
                'integer'
            ]
        ];
    }

    /**
     * @return array
     */
    public function attributes()
    {
        return [
            'name' => '姓名',
            'sex' => '性别',
            'relation' => '与用户关系',
            'avatar' => '头像',
            'morning_rule' => '早餐规则',
            'lunch_rule' => '午餐规则',
            'dinner_rule' => '晚餐规则'
        ];
    }

    /**
     * @return array
     */
    public function messages()
    {
        return [
            'avatar.required' => '请上传一张:attribute',
            'name.required' => '请填写:attribute',
            'sex.required' => '请选择:attribute',
            'relation.required' => '请选择:attribute',
            'morning_rule.required' => '请选择:attribute',
            'morning_rule.integer' => ':attribute格式错误',
            'lunch_rule.required' => '请选择:attribute',
            'lunch_rule.integer' => ':attribute格式错误',
            'dinner_rule.required' => '请选择:attribute',
            'dinner_rule.integer' => ':attribute格式错误'
        ];
    }
}
